/*
 * Copyright 2011 Clean GWT
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleanform.gwt.chinesechess.shared.model;

/**
 * The chess.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
public class Chess {
	public static final int EMPTY = 0;
	public static final int KING = 1;
	public static final int ROOK = 2;
	public static final int HORSE = 3;
	public static final int CANNON = 4;
	public static final int ELEPHANT = 5;
	public static final int ADVISOR = 6;
	public static final int PAWN = 7;

	public static final String[][] CHESS_FACES = new String[][] { { "將", "車", "馬", "包", "象", "士", "卒" },
			{ "帥", "俥", "傌", "炮", "相", "仕", "兵" } };

	public static final int FORCE_WHITE = 1;
	public static final int FORCE_BLACK = -1;

	public static final int HORSE_HMOVES[] = { -1, -1, -2, -2, 1, 1, 2, 2 };
	public static final int HORSE_VMOVES[] = { -2, 2, -1, 1, -2, 2, -1, 1 };
	public static final int HORSE_HBLOCKS[] = { 0, 0, -1, -1, 0, 0, 1, 1 };
	public static final int HORSE_VBLOCKS[] = { -1, 1, 0, 0, -1, 1, 0, 0 };

	public static final Location KING_MOVES[][][] = new Location[10][6][];

	static {
		KING_MOVES[0][3] = new Location[] { new Location(4, 0), new Location(3, 1) };
		KING_MOVES[0][4] = new Location[] { new Location(3, 0), new Location(5, 0), new Location(4, 1) };
		KING_MOVES[0][5] = new Location[] { new Location(4, 0), new Location(5, 1) };

		KING_MOVES[1][3] = new Location[] { new Location(3, 0), new Location(3, 2), new Location(4, 1) };
		KING_MOVES[1][4] = new Location[] { new Location(3, 1), new Location(5, 1), new Location(4, 0),
				new Location(4, 2) };
		KING_MOVES[1][5] = new Location[] { new Location(5, 0), new Location(5, 2), new Location(4, 1) };

		KING_MOVES[2][3] = new Location[] { new Location(3, 1), new Location(4, 2) };
		KING_MOVES[2][4] = new Location[] { new Location(3, 2), new Location(5, 2), new Location(4, 1) };
		KING_MOVES[2][5] = new Location[] { new Location(5, 1), new Location(4, 2) };
		//
		KING_MOVES[7][3] = new Location[] { new Location(4, 7), new Location(3, 8) };
		KING_MOVES[7][4] = new Location[] { new Location(3, 7), new Location(5, 7), new Location(4, 8) };
		KING_MOVES[7][5] = new Location[] { new Location(4, 7), new Location(5, 8) };

		KING_MOVES[8][3] = new Location[] { new Location(3, 7), new Location(3, 9), new Location(4, 8) };
		KING_MOVES[8][4] = new Location[] { new Location(3, 8), new Location(5, 8), new Location(4, 7),
				new Location(4, 9) };
		KING_MOVES[8][5] = new Location[] { new Location(5, 7), new Location(5, 9), new Location(4, 8) };

		KING_MOVES[9][3] = new Location[] { new Location(3, 8), new Location(4, 9) };
		KING_MOVES[9][4] = new Location[] { new Location(3, 9), new Location(5, 9), new Location(4, 8) };
		KING_MOVES[9][5] = new Location[] { new Location(5, 8), new Location(4, 9) };
	}

	public static final Location ADVISOR_MOVES[][][] = new Location[10][6][];

	static {
		ADVISOR_MOVES[0][3] = new Location[] { new Location(4, 1) };
		ADVISOR_MOVES[0][5] = new Location[] { new Location(4, 1) };
		ADVISOR_MOVES[1][4] = new Location[] { new Location(3, 0), new Location(5, 0), new Location(3, 2),
				new Location(5, 2) };
		ADVISOR_MOVES[2][3] = new Location[] { new Location(4, 1) };
		ADVISOR_MOVES[2][5] = new Location[] { new Location(4, 1) };
		//
		ADVISOR_MOVES[7][3] = new Location[] { new Location(4, 8) };
		ADVISOR_MOVES[7][5] = new Location[] { new Location(4, 8) };
		ADVISOR_MOVES[8][4] = new Location[] { new Location(3, 7), new Location(5, 7), new Location(3, 9),
				new Location(5, 9) };
		ADVISOR_MOVES[9][3] = new Location[] { new Location(4, 8) };
		ADVISOR_MOVES[9][5] = new Location[] { new Location(4, 8) };
	}

	public static final Location ELEMPHAT_MOVES[][][] = new Location[10][9][];
	public static final Location ELEMPHAT_BLOCKS[][][] = new Location[10][9][];
	static {
		ELEMPHAT_MOVES[0][2] = new Location[] { new Location(4, 2), new Location(0, 2) };
		ELEMPHAT_MOVES[0][6] = new Location[] { new Location(4, 2), new Location(8, 2) };
		ELEMPHAT_MOVES[2][0] = new Location[] { new Location(2, 0), new Location(2, 4) };
		ELEMPHAT_MOVES[2][4] = new Location[] { new Location(2, 0), new Location(6, 0), new Location(2, 4),
				new Location(6, 4) };
		ELEMPHAT_MOVES[2][8] = new Location[] { new Location(6, 0), new Location(6, 4) };
		ELEMPHAT_MOVES[4][2] = new Location[] { new Location(4, 2), new Location(0, 2) };
		ELEMPHAT_MOVES[4][6] = new Location[] { new Location(4, 2), new Location(8, 2) };
		//
		ELEMPHAT_MOVES[9][2] = new Location[] { new Location(4, 7), new Location(0, 7) };
		ELEMPHAT_MOVES[9][6] = new Location[] { new Location(4, 7), new Location(8, 7) };
		ELEMPHAT_MOVES[7][0] = new Location[] { new Location(2, 9), new Location(2, 5) };
		ELEMPHAT_MOVES[7][4] = new Location[] { new Location(2, 9), new Location(6, 9), new Location(2, 5),
				new Location(6, 5) };
		ELEMPHAT_MOVES[7][8] = new Location[] { new Location(6, 9), new Location(6, 5) };
		ELEMPHAT_MOVES[5][2] = new Location[] { new Location(4, 7), new Location(0, 7) };
		ELEMPHAT_MOVES[5][6] = new Location[] { new Location(4, 7), new Location(8, 7) };
		//
		ELEMPHAT_BLOCKS[0][2] = new Location[] { new Location(3, 1), new Location(1, 1) };
		ELEMPHAT_BLOCKS[0][6] = new Location[] { new Location(5, 1), new Location(7, 1) };
		ELEMPHAT_BLOCKS[2][0] = new Location[] { new Location(1, 1), new Location(1, 3) };
		ELEMPHAT_BLOCKS[2][4] = new Location[] { new Location(3, 1), new Location(5, 1), new Location(3, 3),
				new Location(5, 3) };
		ELEMPHAT_BLOCKS[2][8] = new Location[] { new Location(7, 1), new Location(7, 3) };
		ELEMPHAT_BLOCKS[4][2] = new Location[] { new Location(3, 3), new Location(1, 3) };
		ELEMPHAT_BLOCKS[4][6] = new Location[] { new Location(5, 3), new Location(7, 3) };
		//
		ELEMPHAT_BLOCKS[9][2] = new Location[] { new Location(3, 8), new Location(1, 8) };
		ELEMPHAT_BLOCKS[9][6] = new Location[] { new Location(5, 8), new Location(7, 8) };
		ELEMPHAT_BLOCKS[7][0] = new Location[] { new Location(1, 8), new Location(1, 6) };
		ELEMPHAT_BLOCKS[7][4] = new Location[] { new Location(3, 8), new Location(5, 8), new Location(3, 6),
				new Location(5, 6) };
		ELEMPHAT_BLOCKS[7][8] = new Location[] { new Location(7, 8), new Location(7, 6) };
		ELEMPHAT_BLOCKS[5][2] = new Location[] { new Location(3, 6), new Location(1, 6) };
		ELEMPHAT_BLOCKS[5][6] = new Location[] { new Location(5, 6), new Location(7, 6) };
	}
}
